
Option Explicit On

Dim inicio As Boolean

Private Sub btnSalir_Click()
    Unload(Me)
End Sub

Private Sub opAleatorio_Click()
    scRed.Enabled = False
    scGreen.Enabled = False
    scBlue.Enabled = False
    frmAnimacion.tipo_color = 1
End Sub

Private Sub opSeleccionar_Click()
    scRed.Enabled = True
    scGreen.Enabled = True
    scBlue.Enabled = True
    frmAnimacion.tipo_color = 2
End Sub

Private Sub scAlto_Change()
    frVentana.Height = scAlto.Value
    If Not (inicio) Then conversion_medidas_out()
End Sub

Private Sub scAncho_Change()
    frVentana.Width = scAncho.Value
    If Not (inicio) Then conversion_medidas_out()
End Sub

Private Sub scVel_Change()
    lbVel.Caption = scVel.Value
    frmAnimacion.velocidad = scVel.Value
End Sub

Private Sub scRed_Change()
    frmAnimacion.gRed = scRed.Value
    mostrar_color()
End Sub

Private Sub scGreen_Change()
    frmAnimacion.gGreen = scGreen.Value
    mostrar_color()
End Sub

Private Sub scBlue_Change()
    frmAnimacion.gBlue = scBlue.Value
    mostrar_color()
End Sub

Private Sub UserForm_Initialize()
    inicio = True
    scVel.Value = frmAnimacion.velocidad
    scRed.Value = frmAnimacion.gRed
    scGreen.Value = frmAnimacion.gGreen
    scBlue.Value = frmAnimacion.gBlue
    mostrar_color()
    conversion_medidas_in()
    If frmAnimacion.tipo_color = 1 Then
        opAleatorio.Value = True
        opSeleccionar.Value = False
        scRed.Enabled = False
        scGreen.Enabled = False
        scBlue.Enabled = False
    Else
        opAleatorio.Value = False
        opSeleccionar.Value = True
        scRed.Enabled = True
        scGreen.Enabled = True
        scBlue.Enabled = True
    End If
    inicio = False
End Sub

Sub mostrar_color()
    lbColor.BackColor = RGB(scRed.Value, scGreen.Value, scBlue.Value)
End Sub

Sub conversion_medidas_in()
    scAlto.Value = frmAnimacion.Height / 7.5
    scAncho.Value = frmAnimacion.Width / 7.5
    frVentana.Height = scAlto.Value
    frVentana.Width = scAncho.Value
End Sub

Sub conversion_medidas_out()
    frmAnimacion.Height = scAlto.Value * 7.5
    frmAnimacion.Width = scAncho.Value * 7.5
End Sub
